unit url_Duplicata;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, QuickRpt, ExtCtrls, QRCtrls, jpeg, DB, DBClient;


type
  Tfrl_Duplicata = class(TForm)
    QuickRep1: TQuickRep;
    QRBand1: TQRBand;
    QRImage1: TQRImage;
    lbRazaoSocial: TQRDBText;
    lbCNPJ: TQRDBText;
    LbRua: TQRDBText;
    lbFaturaValor: TQRDBText;
    lbFONE: TQRDBText;
    lbFaturaNumero: TQRDBText;
    lbCEP: TQRDBText;
    lbDuplicataNumOrdem: TQRDBText;
    lbDuplicataValor: TQRDBText;
    lbVencimento: TQRDBText;
    mMensagemAlerta: TQRMemo;
    lbNomeCliente: TQRDBText;
    lbEndereco: TQRDBText;
    lbCEPCliente: TQRDBText;
    lbMunicipio: TQRDBText;
    lbBairro: TQRDBText;
    lbPracaPagto: TQRDBText;
    lbTelefone: TQRDBText;
    lbCNPJCPF: TQRDBText;
    lbRGIE: TQRDBText;
    mValorExtenso: TQRMemo;
    mMensagemAbaixo: TQRMemo;
    lbDataEmissao: TQRDBText;
    Image1: TImage;
    lbUFEmpresa: TQRDBText;
    lbCidadeEmpresa: TQRDBText;
    CDS: TClientDataSet;
    CDSNomeCliente: TStringField;
    CDSEnderecoCliente: TStringField;
    CDSCEPCliente: TStringField;
    CDSMunicipioCliente: TStringField;
    CDSBairroCliente: TStringField;
    CDSPracaPagto: TStringField;
    CDSTelefoneCliente: TStringField;
    CDSRGIECliente: TStringField;
    CDSCNPJCPFCliente: TStringField;
    CDSRazaoSocialEmpresa: TStringField;
    CDSCNPJEmpresa: TStringField;
    CDSRuaEmpresa: TStringField;
    CDSCEPEmpresa: TStringField;
    CDSFONEEmpresa: TStringField;
    CDSDataEmissao: TStringField;
    CDSDuplicataNumOrdem: TStringField;
    CDSFaturaNumero: TStringField;
    CDSVencimento: TStringField;
    CDSUFCliente: TStringField;
    CDSCidadeEmpresa: TStringField;
    CDSUFEmpresa: TStringField;
    CDSFaturaValor: TStringField;
    CDSDuplicataValor: TStringField;
    CDSCidadeCliente: TStringField;
    procedure QRBand1BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    procedure lbDuplicataValorPrint(sender: TObject; var Value: String);
    procedure lbCNPJCPFPrint(sender: TObject; var Value: String);
    procedure lbCNPJPrint(sender: TObject; var Value: String);
    procedure lbCEPPrint(sender: TObject; var Value: String);
    procedure lbFONEPrint(sender: TObject; var Value: String);
    procedure lbTelefonePrint(sender: TObject; var Value: String);
    procedure lbCEPClientePrint(sender: TObject; var Value: String);
    procedure CDSCalcFields(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frl_Duplicata: Tfrl_Duplicata;
  vlrduplicata : double;
  
implementation

uses biblio;

{$R *.dfm}

procedure Tfrl_Duplicata.QRBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
begin
{  QRImage1.Picture := Image1.Picture;}
  mMensagemAlerta.Lines.Add('');
  mMensagemAbaixo.Lines.Add('');
end;

procedure Tfrl_Duplicata.lbDuplicataValorPrint(sender: TObject;
  var Value: String);
begin
  vlrduplicata := StrToFloat(StringReplace(Value,'.','',[rfReplaceAll]));
end;

procedure Tfrl_Duplicata.lbCNPJCPFPrint(sender: TObject;
  var Value: String);
var
  exte1,exte2,exte3: string;
  ext1: string;
  var1: atext;
  ext2: string;
  a: integer;
begin
  if length(Value) = 14 then
    Value := MascaraCNPJ(value)
  else begin
    if length(Value) = 11 then
      Value := MascaraCpf(value)
  end;
  exte1 := '';
  exte2 := '';
  exte3 := '';
  mValorExtenso.Lines.Clear;
  Extenso(vlrduplicata, 255, 255, ext1, ext2, 4, ' ');
  var1 := Ret_TextJ(ext1, 100);
  for a := 1 to length(var1) do begin
    case a of
      1: Exte1 := var1[a - 1];
      2: Exte2 := var1[a - 1];
      3: Exte3 := var1[a - 1];
    end;
  end;
  mValorExtenso.Lines.Add(exte1 + ' ' + trim(exte2) + ' ' + trim(exte3));
end;

procedure Tfrl_Duplicata.lbCNPJPrint(sender: TObject; var Value: String);
begin
  Value := MascaraCNPJ(value);
end;

procedure Tfrl_Duplicata.lbCEPPrint(sender: TObject; var Value: String);
begin
  value := mascaraCep(value);
end;

procedure Tfrl_Duplicata.lbFONEPrint(sender: TObject; var Value: String);
begin
  Value := MascaraTel(Value);
end;

procedure Tfrl_Duplicata.lbTelefonePrint(sender: TObject;
  var Value: String);
begin
  Value := MascaraTel(Value);
end;

procedure Tfrl_Duplicata.lbCEPClientePrint(sender: TObject;
  var Value: String);
begin
  value := mascaraCep(value);
end;

procedure Tfrl_Duplicata.CDSCalcFields(DataSet: TDataSet);
begin
  CDSCidadeCliente.AsString := CDSMunicipioCliente.AsString + '-' + CDSUFCliente.AsString;
end;

end.
